import json
import os.path

from tensorflow import keras

import mat_util
from automap import train_util


def batch_rename(path):
    for i in range(1, 41):
        try:
            os.rename(path + '/artifact/train' + str(i) + '.npz', path + '/artifact/downsample' + str(i) + '.npz')
            os.rename(path + '/noise/train' + str(i) + '.npz', path + '/noise/downsample' + str(i) + '.npz')
            os.rename(path + '/detail_less/train' + str(i) + '.npz', path + '/detail_less/downsample' + str(i) + '.npz')
        finally:
            continue


if __name__ == '__main__':
    # show_different_noise("E:/download/Dataset/keras/IXI-T1/output/1.png")
    # 显示预测结果
    # show_predict_results(r'E:/download/Dataset/keras/IXI-MRA/output/train/detail_less' )
    # show_predict_results(r'E:/download/Dataset/keras/IXI-T1/output/train/noise' )
    # show_predict_results(r'E:/download/Dataset/keras/IXI-T1/output/train/artifact' )
    # 显示x和y数据
    # show_train_img(r'E:/download/Dataset/keras/IXI-T1/output/train/artifact/downsample3.npz')
    # 显示伪影

#########################################预测##############################################
    # #服务器预测
    # model = keras.models.load_model('/root/models/model_best0.h5')
    # train_model.predict('/root/autodl-tmp/test.mat' ,model=model , normalize=False)
    # mat_util.show_predict_mat_results(r'/root/autodl-tmp')
    # 本地预测
    model = keras.models.load_model(r'E:\download\Dataset\keras\train\local\detail_less\detail_less_model.h5')
    train_util.predict_img(r'E:\download\Dataset\keras\train\local\detail_less\detail_less_test.mat', model=model, normalize=False)
    model = keras.models.load_model(r'E:\download\Dataset\keras\train\local\noise\noise_model.h5')
    train_util.predict_img(r'E:\download\Dataset\keras\train\local\noise\noise_test.mat', model=model, normalize=False)
    model = keras.models.load_model(r'E:\download\Dataset\keras\train\local\artifact\artifact_model.h5')
    train_util.predict_img(r'E:\download\Dataset\keras\train\local\artifact\artifact_test.mat', model=model, normalize=False)
    # 显示预测结果
    mat_util.show_predict_mat_results(r'E:\download\Dataset\keras\train\local\detail_less')
    mat_util.show_predict_mat_results(r'E:\download\Dataset\keras\train\local\artifact')
    mat_util.show_predict_mat_results(r'E:\download\Dataset\keras\train\local\noise')
